<?php
require_once("../../../config.inc.php");
require_once("../../../app/_inc/include.php");

$errMsg = "";

$sSQL = "SELECT * FROM profile ORDER BY description";
if(!$objSDAO->query($sSQL,"sel",array("contOnErr"=>true))){		
	$errMsg .= $sSQL." - ".$objSDAO->error;
}
//output HTML
$aOpz = array("tit2"=>_t("Lista dei profili"));
echo(headerHTML($aOpz));
echo(bodyHTML($aOpz));
//output comandi
$aCmd = array(
	"usrlis"=>array("pag"=>"../user/userList.php",
						"title"=>_t("lista uytenti"),
						"text"=>_t("utenti"),
						"perm"=>"visuten", "align"=>"L"),
	"ins"=>array("pag"=>"profileIns.php",
						"title"=>_t("Inserisci un nuovo profilo"),
						"text"=>_t("nuovo profilo"),
						"perm"=>"newpro"),
	"back"=>array("pag"=>$objUser->getHistory(-1,false),
						"title"=>$objUser->getHistoryText(-1),
						"text"=>$objUser->getHistoryText(-1),
						"perm"=>"")
	);
echo(commandsHTML($aCmd));	
//output dei dati
if($errMsg == ""){
	$numElem = 0;
	echo("<table class='tabl01' width=\"100%\" cellpadding=\"3\" cellspacing=\"2\">\n");
	echo("<tr>" .
			"<td class=\"titl01\"colspan=\"2\">"._t("Profili")."</td>" .
		"</tr>\n");
	echo("<tr>" .
			"<td class=\"tabh01\" width=\"10%\">"._t("description")."</td>" .
			"<td class=\"tabh01\" width=\"90%\">"._t("note")."</td>" .
		"</tr>\n");
	while($row = $objSDAO->fetch("sel")){
		if($objSDAO->error == ""){
			$numElem ++;
			echo("<tr>" .
					"<td class=\"text01\"><a class=\"text01\" ".goToPag("profileView.php?xsn=".XSN."&id=".$row["id_profile"]).">".sxHE($row["description"])."</a></td>" .
					"<td class=\"text01\">".sxHE($row["note"])."</td>" .
				"</tr>\n");
		}else{
			echo("<tr>" .
					"<td class=\"text01\" colspan=\"5\">".$objSDAO->error."</td>" .
				"</tr>\n");
		}
	}
	if($numElem == 0)
		echo("<tr>" .
				"<td class=\"text01\" colspan=\"2\">"._t("Nessun profilo definito")."</td>".
			"</tr>\n");
	echo("</table>\n");
}else{
	
}
echo(commandsHTML($aCmd));
echo(footerHTML());
$objSDAO->close();
?>
